import ai.kastrax.core.agent.Agent
import ai.kastrax.core.agent.AgentGenerateOptions
import ai.kastrax.core.agent.AgentResponse
import ai.kastrax.core.llm.LlmMessage
import ai.kastrax.core.llm.LlmRole
import io.github.oshai.kotlinlogging.KotlinLogging

private val logger = KotlinLogging.logger {}

/**
 * 简单的 Agent 实现，用于演示目的。
 * 在实际应用中，你应该使用真实的 LLM 提供商。
 */
class SimpleAgent : Agent {
    override val name: String = "${projectNamePascalCase}Agent"
    
    override suspend fun generate(prompt: String, options: AgentGenerateOptions?): AgentResponse {
        logger.info { "Generating response for prompt: $prompt" }
        
        // 在实际应用中，这里应该调用 LLM API
        // 这里只是一个简单的模拟
        val response = "This is a simulated response from ${name}.\n\n" +
                       "You asked: $prompt\n\n" +
                       "In a real application, this would be generated by an LLM."
        
        return AgentResponse(text = response)
    }
    
    override suspend fun generate(
        messages: List<LlmMessage>,
        options: AgentGenerateOptions?
    ): AgentResponse {
        logger.info { "Generating response for ${messages.size} messages" }
        
        // 在实际应用中，这里应该调用 LLM API
        // 这里只是一个简单的模拟
        val lastUserMessage = messages.lastOrNull { it.role == LlmRole.USER }?.content ?: "No user message"
        
        val response = "This is a simulated response from ${name}.\n\n" +
                       "Last user message: $lastUserMessage\n\n" +
                       "In a real application, this would be generated by an LLM."
        
        return AgentResponse(text = response)
    }
}
